<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserFoodTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_food', function (Blueprint $table) {
            $table->comment = '用户食物表';
            $table->increments('id');
            $table->timestamps();
            $table->softDeletes();

            $table->integer('user_builder_id')->comment('用户评测表user_builder.id');
            $table->integer('bmr_user_id')->comment('用户表bmr_users.id');
            $table->integer('food_id')->comment('食物表foods.id');
            $table->integer('food_weight')->comment('食物重量');
            $table->string('food_protein')->comment('蛋白质/克');
            $table->string('food_fat')->comment('脂肪/克');
            $table->string('food_carbohydrate')->comment('碳水化合物/克');
            $table->string('food_category')->comment('食物表名称');
            $table->tinyInteger('is_finish')->default(0)->comment('是否完成');

            $table->index('user_builder_id');
            $table->index('bmr_user_id');
            $table->index('food_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_food');
    }
}
